//
//  JSDemoHomeVC.m
//  JSBaseProject
//
//  Created by Apple on 2017/11/7.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "JSDemoHomeVC.h"
#import "userInfoTitleView.h"
#import "QMUIFloatLayoutView+JSHander.h"
@interface JSDemoHomeVC ()

@property(nonatomic, strong) QMUIFloatLayoutView *floatLayoutView;

@end

@implementation JSDemoHomeVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.extendedLayoutIncludesOpaqueBars = NO;
    JS_WeakSelf(self)
    self.floatLayoutView = [[QMUIFloatLayoutView alloc] initWithFrame:self.view.bounds];
    self.floatLayoutView.padding = UIEdgeInsetsZero;
    self.floatLayoutView.itemMargins = UIEdgeInsetsMake(0, 0, 10, 10);
    self.floatLayoutView.minimumItemSize = CGSizeMake(69, 29);
    [self.view addSubview:self.floatLayoutView];
    
    [self.floatLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(weakself.view);
        make.top.and.left.and.right.equalTo(weakself.view);
    }];
    self.floatLayoutView.backgroundColor = [UIColor orangeColor];
     NSArray<NSString *> *suggestions = @[@"Helps", @"Maintainaaaaaaaaa", @"Liver", @"Health", @"Function", @"Supports", @"Healthy", @"Fat",@"Helps", @"Maintain", @"Liver", @"Health", @"Function", @"Supports", @"Healthy", @"Fat"];
    for (NSInteger i = 0; i < suggestions.count; i ++) {
        userInfoTitleView *v = [userInfoTitleView new];
        v.titleL.text = (NSString *)suggestions[arc4random() % (suggestions.count - 1)];
        v.contenL.text= suggestions[i];
        [self.floatLayoutView addSubview:v];
    }
    [self.floatLayoutView js_getContentSize:CGSizeMake(SCREEN_WIDTH, 0)];
    [self.floatLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo([weakself.floatLayoutView js_getContentSize:CGSizeMake(SCREEN_WIDTH, 0)].height);
    }];
}
- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    JSLog(@"floatLayoutView %@", NSStringFromCGRect(self.floatLayoutView.frame));
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)setNavigationItemsIsInEditMode:(BOOL)isInEditMode animated:(BOOL)animated{
    [super setNavigationItemsIsInEditMode:isInEditMode animated:animated];
    self.navigationItem.title = @"首页";
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
